<%--店铺信息--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="col-md-9">
    <div class="data_list">
        <div class="container-fluid">
            <div class="row" style="padding-top: 20px;">
                <div class="col-md-12">
                    <div class="from">
                        <!--  -->
                        <!-- 上半部分div -->
                        <div class="data_list_title"><span class="iconfont icon-dianpuxinxi24 "></span>&nbsp;店铺信息</div>
                        <div class="container-fluid">
                            <div class="row" style="padding-top: 20px;">
                                <%--                                左边占2/3 右边占1/3--%>
                                <%--    左边--%>
                                <div class="col-md-8">
                                    <form class="form-horizontal" method="post" action="user" enctype="multipart/form-data" >
                                        <div class="form-group">
                                            <input type="hidden" id="fileImg" value="${fileImg}">
                                            <label for="shopname" class="col-sm-3 control-label">店铺名:</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" name="nick" id="shopname" value="${shop.shopName}" readonly>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="shopaddress" class="col-sm-3 control-label">店铺地址:</label>
                                            <div class="col-sm-8">
                                                <input class="form-control" name="nick" id="shopaddress" value="${shop.shopLoc}" readonly>
                                            </div>
                                        </div>
                                        <div>
                                            <div class="form-group">
                                                <label for="mood" class="col-sm-3 control-label">店铺头像:</label>
                                                <div class="col-sm-1"><img id="shopImg" class="form-img" src="../statics/images/shop/${shop.shopImg}"></div>
                                                <div class="col-sm-8">
                                                    <input id="updateImg" class="form-file" type="file">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
<%--        数据库时间比较时可以通过字符串，但是时间是严格的 HH:mm:ss,可以让java toString            --%>
<%--        假设每天的营业时间固定--%>
                                            <label for="week1" class="col-sm-3 control-label">营业时间:</label>

                                            <div class="col-sm-8 control-label mytimebox"><input id="week1" name="week1" type="text" placeholder="时间格式为8:30-21:30" title="时间格式为8:30-21:30" value="${shop.shopWorkTime}"></div>
                                            <div class="col-sm-11 control-label">
                                                周一<input type="checkbox"<c:if test="${(shop.WorkType%2)>=1}">checked</c:if> value="1" >
                                                周二<input type="checkbox"<c:if test="${(shop.WorkType%4)>=2}">checked</c:if> value="2">
                                                周三<input type="checkbox"<c:if test="${(shop.WorkType%8)>=4}">checked</c:if> value="3">
                                                周四<input type="checkbox"<c:if test="${(shop.WorkType%16)>=8}">checked</c:if> value="4">
                                                周五<input type="checkbox"<c:if test="${(shop.WorkType%32)>=16}">checked</c:if> value="5">
                                                周六<input type="checkbox"<c:if test="${(shop.WorkType%64)>=32}">checked</c:if> value="6">
                                                周七<input type="checkbox"<c:if test="${(shop.WorkType%128)>=64}">checked</c:if> value="7">
                                            </div>
<%--                                            开始时间--%>
                                        </div>
                                        <div class="form-group">
                                            <label for="mood" class="col-sm-3 control-label">简介:</label>
                                            <div class="col-sm-8">
                                                <textarea class="form-control" name="mood" id="mood" rows="3">${shop.shopInfo}</textarea>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <button type="submit" id="btn" class="btn btn-success" onclick="return updateUser();">保存修改</button>&nbsp;&nbsp;
                                                <button type="submit" id="redo" class="btn btn-success" onclick="return redo();">复原</button>&nbsp;&nbsp;
                                                <span style="color:red; font-size: 12px;" id="msg"></span>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                                <%--    右边--%>
                                <div class="col-md-4">
                                    <img style="width:100%;" src="../statics/images/shop/${shop.shopImg}">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $('#updateImg').change(function (){
        var imgpath = $('#fileImg').val()
        var files = $('#updateImg')[0].files[0]
        var data = new FormData();
        //下面的键值对不是随意的 和后端参数一致 必须是POST请求
        data.append('file',files)
        data.append('fileImg',imgpath)
        $.ajax({
            url:'../util/filePost.data',
            type:'POST',
            data:data,
            processData:false,
            contentType:false,
            dataType:'json',
            success:function (result){
                console.log(result.filename)
                //    通过在服务器(导航栏有ip地址)的相对路径重新加载
                //前面./作用是返回到服务器项目根地址 -- 规定的路径最好就是原来用户存的路径，这样只需要修改数据库的名就行了，下次加载就能在原路径加载
                $("#shopImg").attr("src", "../statics/images/shop/"+result.filename)
            },
        })
    })
</script>
</script>
<style>
    .control-label{
        padding-bottom: 7px;
    }
    .form-file{
        padding-bottom: 7px;
        padding-top: 7px;
    }
    .form-img{
        height: 34px;
        width: 34px;
    }
    .mytimebox{
        text-align: right;

    }
</style>